package com.cww.study.service.impl;

import com.cww.study.service.ISysDbTimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

/**
 * @program: cww_project
 * @description:
 * @author: 陈英俊
 * @create: 2022-03-08 14:26
 */
@Service
public class ISysDbTimeServiceImpl implements ISysDbTimeService {

    @Autowired
    private JdbcTemplate jdbcTemplate;


    private String getDbTime(String format) {
        String sqlQuery = "SELECT DATE_FORMAT(NOW(),?) from dual";
        String result = jdbcTemplate.queryForObject(sqlQuery, new Object[]{format}, String.class);
        return result;

    }

    @Override
    public String getDbTime14() {
        return getDbTime("%Y%m%d%H%i%S");
    }

}
